package com.zzw.util;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.UUID;

public class StringUtils {
    private static char[] BASE64 = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789".toCharArray();

    public static String createSEQ_NO() {
        StringBuffer sb = new StringBuffer();
        String time = new SimpleDateFormat("yyyyMMddHHmmssSSS").format(new Date());
        sb.append(time).append(generate16Uuid());
        return sb.toString();
    }

    private static String generate16Uuid() {
        StringBuffer shortBuffer = new StringBuffer();
        String uuid = UUID.randomUUID().toString().replace("-", "");
        for (int i = 0; i < 16; i++) {
            String str = uuid.substring(i * 2, i * 2 + 2);
            int x = Integer.parseInt(str, 16);
            shortBuffer.append(BASE64[x % 0x3E]);
        }
        return shortBuffer.toString();
    }
}
